﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InvoiceReport.aspx.cs" Inherits="Web.Invoice.InvoiceReport" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <script type="text/javascript">
            function Print() {
                alert("SDSDSDSFSF");
                var report = document.getElementById("<%=ReportViewer1.ClientID %>");
                var div = report.getElementsByTagName("DIV");
                var reportContents;
                for (var i = 0; i < div.length; i++) {
                    if (div[i].id.indexOf("VisibleReportContent") != -1) {
                        reportContents = div[i].innerHTML;
                        break;
                    }
                }
                var frame1 = document.createElement('iframe');
               
                frame1.name = "frame1";
                frame1.style.position = "absolute";
                frame1.style.top = "-1000000px";
                document.body.appendChild(frame1);
                var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
                frameDoc.document.open();
                frameDoc.document.write('<html><head><title>RDLC Report</title>');
                frameDoc.document.write('</head><body style = "font-family:arial;font-size:10pt;">');
                frameDoc.document.write(reportContents);
                frameDoc.document.write('</body></html>');
                frameDoc.document.close();
                setTimeout(function () {
                    
                    window.frames["frame1"].focus();
                    window.frames["frame1"].print();
                    document.body.removeChild(frame1);
                }, 500);
            }
            function onClose() {
                window.close();
            }
        </script>
        <div style="margin-bottom: 6px">
            <asp:Button ID="print" runat="server" Text="Print" OnClick="print_Click" Width="100px" />
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="onClose();" Width="100px" />
        </div>
        <div>
            <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana"
                Width="100%" Height="100%" WaitMessageFont-Size="14pt" AsyncRendering="False" SizeToReportContent="True" ShowPrintButton="true">
                <LocalReport ReportPath="Report_Template\Report.rdlc">
                </LocalReport>
            </rsweb:ReportViewer>
            <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="xpressflower.DataSet1TableAdapters."></asp:ObjectDataSource>
            <iframe id="frmPrint" name="IframeName" width="50"
                height="50" runat="server"
                style="visibility:hidden"></iframe>
        </div>
    </form>
</body>
</html>
